#include "classtype.h"

std::string ClassTypeNode::fullName() const
{
	std::string result=*m_name;
	if (m_template_args)
	{
	  result+="[";
	  const std::vector<IdentifierNode *> & v=m_template_args->vector();
      for (unsigned int i=0;i<v.size();i++)
	  {
		  result+=v[i]->data();
		  if (i!=v.size()-1)
			  result+=",";
	  }
	  result+="]";
	}
	return result;
}

void  ClassTypeNode::write(GraphStream * s)
{
 this->accept(s);
 fprintf(s->stream,"\tnode_%d [ label=\"(%d,%d)\\nClassType - %s\" shape=\"rectangle\"]\n",this->number(),this->line(),this->position(),this->fullName().c_str());
 if (m_template_args)
 {
	 m_template_args->write(s);
	 fprintf(s->stream,"\tnode_%d -> node_%d\n",number(),m_template_args->number());
 }
}

std::string ClassTypeNode::getSimpleSignature() const
{
	std::string result="L";
	result+=*m_name;
	result+=";";
	return result;
}

std::string ClassTypeNode::getFullSignature() const
{
 std::string result="L";
 result+=*m_name;
 if (m_template_args)
 {
	  result+="<";
	  const std::vector<IdentifierNode *> & v=m_template_args->vector();
      for (unsigned int i=0;i<v.size();i++)
	  {
		  result+="L";
		  result+=v[i]->data();
		  result+=";";
	  }
	  result+=">";
 }
 result+=";";
 return result;
}